<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;


/**
 * 赌王可用余额流水模型
 */
class KingBalanceLog extends ModelBase
{

    protected $insert = ['create_time','serial_number'];

    /**
     * 连用户表
     */
    public function member(){
        return $this->belongsTo('Member','user_id','id');
    }



    /**
     * 获取类型信息
     */
    public function getTypeTextAttr(){
         $arr=['','下注','奖金'];
        return $arr[$this->data['type']];
    }

    /**
     * 流水号自动完成
     */
    public function setSerialNumberAttr()
    {

        return 'KB'.date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
    }






    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr($value)
    {

        return TIME_NOW;
    }

    /**
     * 时间自动完成
     */
    public function getCreateTimeAttr($value)
    {

        return date('Y-m-d H:i:s',$value);
    }

//    public function  getRemarkAttr($value){
//
//        $lang=isset($_REQUEST['lang'])?$_REQUEST['lang']:'';
//        return   baidu_translate($value,$lang);
//
//
//    }


}
